Git筆記 - 建立及讀取github repo


目標

語法:

建立 .git
git init
(在本地端的fold需要使用此在檔案裡建立new repository\
github上創立repository就會自動加載.git)

將[repo's github address]檔案下載至目前的目錄位置
public repo:
git clone [repo's https://github...]
private repo:
git clone [repo's https://token@github...]

練習

1.先在桌面建立一個空資料夾

cd Desktop
mkdir myrepo

2.用 git status檢查看看myrepo的狀態

fatal : not a git repository (or any of the parent directories): .git)

--> 表示檔案中沒有 .git file ,無法查找git status

3.進到file裡面初始git
(1)

cd myrepo
git init

(2) 直接到檔案裡右鍵點入git bash

git init

結果
//Initialized empty Git repository in C:/Users/user/Desktop/myrepo/.git/
檔案已經建了一個repository
這時候git status就可以查找狀態

On branch master
No commits yet
nothing to commit (create/copy files and use "git add" to track)

(4) 在github上建立一個新的repository - practice_repo
(github中建立的 new repo本身就已經有.git file)
並且找到 practice_repo中的複製網址

將這個新的repository下載到桌面

cd ..
git clone [ repo's address ]

這時檔案下載成功 ,但如果當初practice_repo設定為private則會下載失敗

如何 git clone private repo

當需要clone private repo時,需要repo擁有者發行的token
表示有授權可以開放clone

A: 擁有practice_private_repo
B: 想讀取practice_private_repo

A: 創造token給B
A的github --> settign --> developer setting
--> personal access token (PAT) --> genarate new token
最後token順利產生把它複製下來

B:使用指令跟token來clone:

// for private
git clone https://token@github.com/account/repo.git
// for public
git clone https://github.com/account/repo.git
git clone https://^[[200~b~g@github.com/LTN917/practice_private_repo.git

下載成功!








你可能感興趣的文章

JavaScript - GoToTop 作法

JavaScript - GoToTop 作法

How to solve the perpetual loading issue in Evernote? Evernote 一直轉圈圈的解決辦法

How to solve the perpetual loading issue in Evernote? Evernote 一直轉圈圈的解決辦法

HTML 盒模型 (Box model)

HTML 盒模型 (Box model)






留言討論